/*
 * =====================================================================================
 *
 *       Filename:  FactoryMethod.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2015年01月25日 17时44分04秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  LiuYi (), swliuyi@gmail.com
 *   Organization:  
 *
 * =====================================================================================
 */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <limits.h>
#include <iostream>
//#include  <tr1/memory>
#include  <memory>


using namespace std;

class LeiFeng
{
    public:
        void Sweep()
        {
            cout<<"Sweep"<<endl;
        }
        void Wash()
        {
            cout<<"Wash"<<endl;
        }
        void BuyRice()
        {
            cout<<"BuyRice"<<endl;
        }
};

class UnderGraduate : public LeiFeng { };
class Volunteer : public LeiFeng {};

class IFactory
{
    public:
        virtual LeiFeng * CreateLeiFeng() = 0;
};

class UnderGraduateFactory : public IFactory
{
    public:
        LeiFeng * CreateLeiFeng()
        {
            return new UnderGraduate();
        }
};

class VolunteerFactory : public IFactory
{
    public:
        LeiFeng * CreateLeiFeng()
        {
            return new Volunteer();
        }
};

int main(int argc, char *argv[])
{
   // tr1::
    shared_ptr<UnderGraduateFactory> factory(new UnderGraduateFactory());
   // tr1::
    shared_ptr<LeiFeng>  student(factory->CreateLeiFeng());
    student->Sweep();
    student->Wash();
    student->BuyRice();
}
